﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">
    <title>任务待办</title>
    <link href="/CSS/bootstrap3.3.5/css/bootstrap.css" rel="stylesheet" type="text/css" />
    <link href="/CSS/font-awesome-4.3.0/css/font-awesome.css?v=4.3.0" rel="stylesheet">
    <link href="/CSS/V3/jsTree/style.min.css" rel="stylesheet">
    <link href="/CSS/V3/animate.css" rel="stylesheet">
    <link href="/CSS/V3/style.css?v=2.2.0" rel="stylesheet">
    <link href="/CSS/V3/BaseClassV3.css" rel="stylesheet" />
    <script src="/Scripts/jquery-1.11.2.min.js"></script>
    <script src="/CSS/bootstrap3.3.5/js/bootstrap.js"></script>
    <script src="/JqueryPlug/V3/jsTree/jstree.min.js"></script>
    <script src="/JqueryPlug/laypage/laypage.js"></script>
    <script src="/Scripts/avalon.js"></script>
    <script src="/Scripts/jquery-migrate-1.1.0.min.js"></script>
    <script src="/Scripts/SZHLCommon.js?jsver=5"></script>
    <script>
        var strID = ComFunJS.getQueryString("ID", 0);
        var index = parent.layer.getFrameIndex(window.name);
        var model = avalon.define({
            $id: "APP_RCTX",
            username: ComFunJS.getnowuser(),
            menutype: "",
            CommonData: [],
            type: "0",
            seltype: "0",
            peo: "0",
            selpeo: "0",
            content: "",
            selcontent: "",
            addRCTX: function () {
                parent.ComFunJS.winviewform("/View/APPBaseView/APP_ADD_WF.html?FormCode=RCTX&FrameName=frameRCTX", "添加数据", "1000", "");
                parent.layer.close(index);
            },
            ModityRCTX: function (Id) {
                
                parent.ComFunJS.winviewform("/View/APPBaseView/APP_ADD_WF.html?FormCode=RCTX&FrameName=frameRCTX&ID=" + Id, "编辑数据", "1000", "");
                parent.layer.close(index);
            },
            deltx: function (el, event) {
                event.stopPropagation();
                parent.ComFunJS.winconfirm('你确定要删除此待办吗？', function () {
                    $.getJSON("/API/FTAPI.ashx?Action=DELRWDB", { P1: el.ID }, function (resultData) {
                        if (resultData.ErrorMsg == "") {
                            model.CommonData.remove(el);
                            parent.ComFunJS.winsuccess('删除成功');
                        }

                    });
                }, function () { })
            },
            addZRW: function (ID) {
                parent.ComFunJS.winviewform("/View/APPBaseView/APP_ADD_WF.html?FormCode=RCTX&FrameName=frameRCTX&TopID=" + ID, "添加数据", "1000", "");
                parent.layer.close(index);
            },
            viewZRW: function (ID) {
                parent.ComFunJS.winviewform("/ViewV3/APPBaseView/APP_ZRW.html?ID=" + ID + "&pageType=view&r=" + Math.random(), "子任务", "1000", "");
                parent.layer.close(index);
            },
            addalert: function (el) {
                var urs = '';
                if (el.RWCYR) {
                    if (el.RWCYR.indexOf(el.RWFZR) != -1) {
                        urs = el.RWCYR;
                    }
                    else {
                        urs = el.RWFZR + ',' + el.RWCYR;
                    }
                }
                else {
                    urs = el.RWFZR;
                }
                parent.ComFunJS.winviewform("/View/APPBaseView/APP_ADD_WF.html?FormCode=TXSX&ausername=" + urs + "&acode=dbsx&aid=" + el.ID, "添加提醒", "1000", "");
                parent.layer.close(index);
            },
            enterDB: function (el, dom) {
                if ($(dom).parent().find('.dbztinfo').is(":hidden")) {
                    $('.dbztinfo').hide('fast');
                    $(dom).parent().find('.dbztinfo').show('fast')
                } else {
                    $(dom).parent().find('.dbztinfo').hide('fast')
                }

            },
            inputevent: function (event) { //输入框事件
                event.stopPropagation();
            },
            addPL: function (el, dom, event) {
                if (event) {
                    event.stopPropagation();
                }
                var content = $(dom).parent().parent().find(".plnr").val();
                if (content == "") {
                    parent.ComFunJS.winwarning("请输入批注内容");
                } else {
                    $.post('/API/FTAPI.ashx?Action=ADDCOMENT', { "P1": content, "MsgType": "RCTX", "MsgLYID": el.ID }, function (result) {
                        var result = $.parseJSON(result);
                        if (result.ErrorMsg == "") {
                            el.PLList.push(result.Result)
                            $(dom).parent().parent().find(".plnr").val("")
                        }
                    })
                }

            },
            completeDB: function (el, event, dom) {//修改待办状态
                event.stopPropagation();
                if ($(dom).hasClass("icon-gouxuan")) {
                    $(dom).removeClass("icon-gouxuan");
                    $(dom).addClass("icon-weigouxuan");
                }
                else {
                    $(dom).removeClass("icon-weigouxuan");
                    $(dom).addClass("icon-gouxuan");
                }
                var ISComplete = $(dom).hasClass("icon-gouxuan") ? "1" : "0";
                if (ISComplete == "1") {

                    $(dom).parent().parent().parent().css({ "background-color": "aliceblue" });
                } else {
                    $(dom).parent().parent().parent().css({ "background-color": "transparent" });
                }
                $.getJSON('/API/FTAPI.ashx?Action=COMPLETERCTX', { "P1": el.ID, "P2": ISComplete }, function (result) {
                    if (result.ErrorMsg == "") {
                        parent.ComFunJS.winsuccess("操作成功");
                    }
                })
            },
            //键盘提交事件
            jptj: function (el, dom, event) {
                if (event.ctrlKey && (event.keyCode == 13 || event.keyCode == 10)) {

                    model.addPL(el, dom);

                }
            },
            GetDBDataList: function () {
                $.getJSON("/API/FTAPI.ashx?Action=GETZRWDATA", { P1: strID }, function (resultData) {
                    if (resultData.ErrorMsg == "") {
                        model.CommonData.clear();
                        model.CommonData = resultData.Result;
                    }
                });
            },
            YC: function () {
                var obj = $(this).parent().parent().find(".social-footer");
                if (obj.is(":hidden")) {
                    obj.show();
                }
                else {
                    obj.hide();
                }
            },
            queryuser: ComFunJS.getnowuser(),
            username: ComFunJS.getnowuser()
        })
        avalon.ready(function () {
            ComFunJS.initsetajax();
            model.GetDBDataList();
        })

        function rwzt(str) {
            if (str == "0") {
                return '<label class="label label-danger" style="margin-right:10px">正在进行</label>';
            }
            else if (str == "1") {
                return '<label class="label label-default" style="margin-right:10px">已结束</label>';
            }
        }
    </script>

</head>
<body class="gray-bg" ms-controller="APP_RCTX">

    <div class="wrapper wrapper-content  animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="social-feed-separated" style="margin-top:10px">

                    <div class="social-feed-box" ms-repeat-el="CommonData" style="border:0;border-bottom: 1px solid #e7eaec;">

                        <div class="pull-right social-action dropdown" style="margin-bottom:0px;">
                            <a class=" btn btn-primary btn-xs btntool" ms-if="el.ISGB"><i ms-on-click="completeDB(el,event,this)" class="iconfont icon-weigouxuan" style="font-size: 12px; margin-right: 3px; color:white"></i>关闭任务</a>
                            <a class=" btn btn-primary btn-xs btntool" ms-attr-dataid="el.ID" ms-attr-dbnr="el.Name" ms-attr-leibie="el.LeiBie" ms-attr-txdate="el.TXTime" ms-click="ModityRCTX(el.ID)" ms-attr-txr="el.TXUser" ms-if="el.CRUser==username"><i class="fa fa-pencil"></i> 编辑 </a>
                            <a class="btn btn-danger btn-xs btntool" style="margin-right:15px" ms-if="el.CRUser==username" ms-click="deltx(el,event)"><i class="fa fa-trash-o"></i> 删除 </a>
                            <a class="btn btn-white btn-xs" ms-click="YC()"><i class="fa fa-angle-down"></i> </a>
                        </div>

                        <div class="social-avatar" style="line-height: 23px;">
                            <p>
                                {{rwzt(el.RWStatus)|html}}<label class="label label-danger" style="margin-right:10px" ms-if="el.LeiBie=='重要'">{{el.LeiBie}}</label>
                            </p>
                        </div>

                        <div class="social-avatar" style="padding-top:0px">
                            <p>
                                {{el.RWTitle|html}}
                            </p>
                        </div>

                        <div class="social-body" style=" padding-top: 0px; padding-bottom: 0px; ">

                            <p class="jnperson">

                                <span>负责人：</span><span class="text-success"><span>{{ComFunJS.convertuser(el.RWFZR)}}</span></span>
                                <span style=" padding-left:10px;" ms-if="el.RWCYR.length>0">参与人：</span>
                                <span class="text-success"><span style="margin-right:10px" ms-repeat-user="el.RWCYR.split(',')">{{ComFunJS.convertuser(user) }}</span></span>
                                <small class="pull-right btntool">
                                    <span class="text-danger">{{el.RWJZDate|date("yyyy年MM月dd日")}}</span>
                                    <a class="" style="margin-left:10px;" ms-click="addalert(el)">添加提醒</a>
                                </small>
                            </p>

                        </div>

                        <div class="social-body" style=" padding-top: 0px; padding-bottom: 0px; ">

                            <p>
                                <span>子任务：</span><span><span>{{el.ZRWCount}}个</span></span>
                                <a class=" btn btn-primary btn-xs" ms-click="addZRW(el.ID)" > 添加子任务 </a>
                                <a class=" btn btn-primary btn-xs" ms-if="el.ZRWCount>0" ms-click="viewZRW(el.ID)"> 查看 </a>
                            </p>
                        </div>

                        <div class="social-footer" style="display:none">

                            <div class="social-comment" ms-repeat-item="el.PLList">
                                <span class="pull-left">
                                    <img alt="image" ms-attr-src="'/Upload/TX/'+item.CRUser+'.jpg'" onerror="javascript: this.src = '/images/TX/default.png'">
                                </span>
                                <div class="media-body">
                                    <span style="color: #3085DB;">
                                        {{item.CRUserName}}
                                    </span> {{item.MSGContent}}
                                    <br /> -
                                    <small class="text-muted">{{item.CRDate|date("MM月dd日 HH:mm")}}</small>
                                </div>
                            </div>

                            <div class="social-comment">
                                <span class="pull-left">
                                    <img alt="image" ms-attr-src="'/Upload/TX/'+username+'.jpg'" onerror="javascript: this.src = '/images/TX/default.png'">
                                </span>
                                <div class="media-body">
                                    <div class="input-group">
                                        <input type="text" class="form-control plnr" placeholder="填写内容(按Ctrl+Enter直接提交)" ms-keypress="jptj(el,this,event)" />
                                        <span class="input-group-btn">
                                            <button type="button" class="btn btn btn-primary " ms-on-click="addPL(el,this,event)">  发表</button>
                                        </span>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

</body>
</html>
